<?php


namespace App\Api\Controllers;


use App\Api\Controllers\UploadController as file;
use App\Models\Area;
use App\Models\Jd;
use App\Models\Order;
use App\Models\Pay\Notify;
use App\Models\Product;
use App\Models\ProductSku;
use App\Models\Rule;
use EclpOrderQueryOrderPacksRequest;
use Illuminate\Http\Request;
use JdClient;
use LdopReceiveTraceGetRequest;


class IndexController extends Controller
{
    public function test()
    {

    }

    //关于
    public function about()
    {
        $res = Rule::where('key','about_us')->first();
        $data = [];
        $data[] = $res?$res['content']:[];
        return $this->responseData($data);
    }

    //客户服务
    public function service()
    {
        $time = Rule::where('key','service_time')->first();
        $tel = Rule::where('key','service_telephone')->first();
        $data = [
            'service_time' => $time?$time['value']:'',
            'service_telephone' => $tel?$tel['value']:'',
        ];
        return $this->responseData($data);
    }

    public function uploads(Request $request)
    {
        if(!$request->imgs){
            return $this->responseFailed('参数错误');
        }
        $file = new file();
        $res = $file->uploadImage($request->file('imgs'));
        if(!$res['code']){
            return $this->responseFailed($res['msg']);
        }
        return $res;
    }

    public function area(Request $request)
    {
        $pid = $request->input('pid',0);
        $areaList = Area::where('pid',$pid)
            ->select('pid','id','name')
            ->get()
            ->toArray();

        return $this->responseData($areaList);
    }
}